package com.merge;

import com.common.FileReaderUtils;
import com.merge.constant.FileConstant;
import com.merge.pojo.Data;
import com.merge.pojo.SliceFile;

public class FileRead {

    /**
     * 获取下行数据
     * @param sliceFile
     * @param pipeQueueName
     * @return
     */
    public static Data getNextLineData(SliceFile sliceFile, String pipeQueueName) {
        String path = sliceFile.getPath();
        String value = FileReaderUtils.readNextLine(path);
        if (value == null) return null;
        return new Data(Integer.valueOf(value), pipeQueueName);
    }

    public static void main(String[] args) {
        String name = FileConstant.SLICE_FILE_PROFIX + 1;
        System.out.println(name);
        SliceFile sliceFile = new SliceFile(name,  10);
        Data data = getNextLineData(sliceFile, "slice_queue_1");
        System.out.println(data.getValue());
    }
}
